var AppMenuButton = new Lang.Class({
Name: 'AppMenuButton',
Extends: PanelMenu.Button,
+ Signals: {'changed': {}},
_init(panel) {
this.parent(0.0, null, true);
this._visible = this._gtkSettings.gtk_shell_shows_app_menu &&
!Main.overview.visible;
if (!this._visible)
- this.actor.hide();
+ this.hide();
this._overviewHidingId = Main.overview.connect('hiding', this._sync.bind(this));
this._overviewShowingId = Main.overview.connect('showing', this._sync.bind(this));
this._showsAppMenuId = this._gtkSettings.connect('notify::gtk-shell-shows-app-menu',
this._visible = true;
this.actor.reactive = true;
- this.actor.show();
+ this.show();
Tweener.removeTweens(this.actor);
Tweener.addTween(this.actor,
{ opacity: 255,
time: Overview.ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete() {
- this.actor.hide();
+ this.hide();
},
onCompleteScope: this });
},
this._menuManager.addMenu(menu);
},
- destroy() {
+ _onDestroy() {
if (this._appStateChangedSignalId > 0) {
let appSys = Shell.AppSystem.get_default();
appSys.disconnect(this._appStateChangedSignalId);
}
});
-Signals.addSignalMethods(AppMenuButton.prototype);
-
var ActivitiesButton = new Lang.Class({
Name: 'ActivitiesButton',
Extends: PanelMenu.Button,
var ButtonBox = new Lang.Class({
Name: 'ButtonBox',
+ Extends: St.Widget,
_init(params) {
params = Params.parse(params, { style_class: 'panel-button' }, true);
- this.actor = new Shell.GenericContainer(params);
- this.actor._delegate = this;
+
+ this.parent(params);
+
+ this.actor = this;
+ this._delegate = this;
this.container = new St.Bin({ y_fill: true,
x_fill: true,
child: this.actor });
- this.actor.connect('get-preferred-width', this._getPreferredWidth.bind(this));
- this.actor.connect('get-preferred-height', this._getPreferredHeight.bind(this));
- this.actor.connect('allocate', this._allocate.bind(this));
-
- this.actor.connect('style-changed', this._onStyleChanged.bind(this));
+ this.connect('style-changed', this._onStyleChanged.bind(this));
this._minHPadding = this._natHPadding = 0.0;
},
this._natHPadding = themeNode.get_length('-natural-hpadding');
},
- _getPreferredWidth(actor, forHeight, alloc) {
- let child = actor.get_first_child();
+ vfunc_get_preferred_width(forHeight) {
+ let child = this.get_first_child();
+ let minimumSize, naturalSize;
- if (child) {
- [alloc.min_size, alloc.natural_size] = child.get_preferred_width(-1);
- } else {
- alloc.min_size = alloc.natural_size = 0;
- }
+ if (child)
+ [minimumSize, naturalSize] = child.get_preferred_width(-1);
+ else
+ minimumSize = naturalSize = 0;
+
+ minimumSize += 2 * this._minHPadding;
+ naturalSize += 2 * this._natHPadding;
- alloc.min_size += 2 * this._minHPadding;
- alloc.natural_size += 2 * this._natHPadding;
+ return [minimumSize, naturalSize];
},
- _getPreferredHeight(actor, forWidth, alloc) {
- let child = actor.get_first_child();
+ vfunc_get_preferred_height(forWidth) {
+ let child = this.get_first_child();
- if (child) {
- [alloc.min_size, alloc.natural_size] = child.get_preferred_height(-1);
- } else {
- alloc.min_size = alloc.natural_size = 0;
- }
+ if (child)
+ return child.get_preferred_height(-1);
+
+ return [0, 0];
},
- _allocate(actor, box, flags) {
- let child = actor.get_first_child();
+ vfunc_allocate(box, flags) {
+ this.set_allocation(box, flags);
+
+ let child = this.get_first_child();
if (!child)
return;
var Button = new Lang.Class({
Name: 'PanelMenuButton',
Extends: ButtonBox,
+ Signals: {'menu-set': {} },
_init(menuAlignment, nameText, dontCreateMenu) {
this.parent({ reactive: true,
accessible_name: nameText ? nameText : "",
accessible_role: Atk.Role.MENU });
- this.actor.connect('event', this._onEvent.bind(this));
- this.actor.connect('notify::visible', this._onVisibilityChanged.bind(this));
+ this.connect('event', this._onEvent.bind(this));
+ this.connect('notify::visible', this._onVisibilityChanged.bind(this));
+ this.connect('destroy', this._onDestroy.bind(this));
if (dontCreateMenu)
this.menu = new PopupMenu.PopupDummyMenu(this.actor);
},
setSensitive(sensitive) {
- this.actor.reactive = sensitive;
- this.actor.can_focus = sensitive;
- this.actor.track_hover = sensitive;
+ this.reactive = sensitive;
+ this.can_focus = sensitive;
+ this.track_hover = sensitive;
},
setMenu(menu) {
this.menu.actor.style = ('max-height: %spx;').format(maxHeight);
},
- destroy() {
- this.actor._delegate = null;
-
+ _onDestroy() {
if (this.menu)
this.menu.destroy();
- this.actor.destroy();
-
- this.emit('destroy');
}
});
-Signals.addSignalMethods(Button.prototype);
/* SystemIndicator:
*